using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Routing;
using Kollektiv.Web.Mvc;
using System.Runtime.Serialization;
using Kollektiv.Config;

namespace Kollektiv
{	
	public class KollektivApplication : System.Web.HttpApplication
	{		
		public static void RegisterRoutes (RouteCollection routes)
		{
            routes.Add(RouteService.MainInstance.ID, RouteService.MainInstance.Route);

			foreach (RouteService routeService in RouteService.GetInstances()) {
				routes.Add (routeService.ID, routeService.Route);
			}
		}

		protected void Application_Start ()
		{
            ConfigService.SetResourcePrefix("Config.");

            // TODO: move to web.config
            ConfigService.SetDirectory(@"/Users/ghost/Documents/Visual Studio 2010/Projects/Kollektiv/Kollektiv/Config");

            ConfigService.SetResourceAssembly(typeof(KollektivApplication).Assembly);
			RegisterRoutes (RouteTable.Routes);
		}
	}
}
